package logic

import (
	"context"
	"house/models/mysql"

	"house/houserpc/houserpc"
	"house/houserpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseShowLogic) HouseShow(in *houserpc.HouseShowRequest) (*houserpc.HouseShowResponse, error) {
	// todo: add your logic here and delete this line
	var house mysql.House
	mysql.DB.Debug().Where("id=?", in.HouseId).Order("created_at desc").Find(&house)
	return &houserpc.HouseShowResponse{
		Title:     house.Title,
		Lease:     house.Lease,
		Money:     house.Money,
		Deposit:   house.Deposit,
		Area:      int64(house.Area),
		Ancillary: house.Ancillary,
		UserId:    int64(house.UserId),
	}, nil
}
